using System;
using System.Threading;
using SKBKontur.Cassandra.Proxy.Selectors;

namespace SKBKontur.Cassandra.Proxy.Management
{
    public class OperationalStatistics
    {
        public long TotalOperations;
        public long FailedOperations;
        public long TotalTime;

        public void ReportFailure(StorageOperation operation, long milliseconds, Exception exception)
        {
            Interlocked.Add(ref TotalTime, milliseconds);
            Interlocked.Increment(ref FailedOperations);
        }

        public void ReportSuccess(StorageOperation operation, long milliseconds)
        {
            Interlocked.Add(ref TotalTime, milliseconds);
        }

        public void ReportBegin()
        {
            Interlocked.Increment(ref TotalOperations);
        }
    }
}